<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
 
</head>

<body>
  <div id="app">
    输入体重（kg）:
    <input type="number" v-model.number.lazy="weight">
    输入身高（m）
    <input type="number" v-model.number.lazy="height">
    =>
    指数
    {{index}}
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp({
      data() {
        return {
          weight: 0,
          height: 0
        }
      },
      watch: {
        index (val) {
          if (val > 24.9) {
            alert('你超重了')
          } else  if (val < 18.5) {
            alert('你瘦的很猴一样')
          } else {
            alert('你很正常')
          }
        }
      },
      // config对象 新增 computed属性
      computed: {
        index () {
          return (this.weight / (this.height*this.height)).toFixed(2)
        }
      }
    })
    app.mount('#app')
  </script>
</body>

</html>